package com.example.bottomnavigationdemo.ui.c_notifications

import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProvider
import com.example.bottomnavigationdemo.R
import com.example.bottomnavigationdemo.ui.a_home.HomeViewModel

class NotificationsFragment : Fragment() {

    private lateinit var notificationsViewModel: HomeViewModel
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Log.e("-------->", "NotificationsFragment-onCreate")

    }

    override fun onDestroy() {
        super.onDestroy()
        Log.e("-------->", "NotificationsFragment-onDestroy")
    }

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        notificationsViewModel =
            ViewModelProvider(requireActivity()).get(HomeViewModel::class.java)
        val root = inflater.inflate(R.layout.fragment_notifications, container, false)

        notificationsViewModel.text.observe(requireActivity(), Observer {
            root.findViewById<TextView>(R.id.textView).text = it
        })
        return root
    }

    override fun onResume() {
        super.onResume()
    }
}